using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FastDev;
using UnityEngine.UI;

public class AIAgent : GoapAgent
{
    public override void OnActionFailed(GoapAction goapAction)
    {
        base.OnActionFailed(goapAction);

        GoapState = new GoapState(new Dictionary<string, int>() {

            {AIStateKey2.Eat,1 },
        });

        StartPlan();
    }

    public override void OnPlanFailed(string actionName)
    {
        base.OnPlanFailed(actionName);

        GoapState = new GoapState(new Dictionary<string, int>() {

            {AIStateKey2.Eat,1 },
        });

        StartPlan();
    }

    private Slider slider;

    public Chair Chair;

    public override GoapAction Goal { get; protected set ; }
    public override List<GoapAction> GoapActions { get; protected set ; }

    private void Awake()
    {
        slider = GetComponentInChildren<Slider>();
    }

    private void Start()
    {
        GoapActions.Add(new SitDownAction(this));
        GoapActions.Add(new EatAction(this));

        Goal = new LeaveAction(this);


        GoapState = new GoapState(new Dictionary<string, int>() {

            {AIStateKey2.HasChair,1 },
        });

        StartPlan();

    }

    protected override void Update()
    {
        base.Update();

        if (CurAction != null)
            slider.value = CurAction.Progress;
    }

}
